Translate Telegram audio messages with AI (55 supported languages) v1
工作流概述
这是一个包含13个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "IvgAFAUOSI3biT4L",
"meta": {
"instanceId": "2723a3a635131edfcb16103f3d4dbaadf3658e386b4762989cbf49528dccbdbd"
},
"name": "Translate Telegram audio messages with AI (55 supported languages) v1",
"tags": [],
"nodes": [
{
"id": "f91fa0cf-ea01-4fc0-9ef2-754da399b7fb",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
440,
220
],
"webhookId": "c537cfcc-6c4a-436a-8871-d32f8ce016cb",
"parameters": {
"updates": [
"*"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "Ov00cT0t4h4AFtZ0",
"name": "Telegram account"
}
},
"typeVersion": 1
},
{
"id": "057ae05f-2c7d-48c5-a057-a6917a88971c",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1240,
0
],
"parameters": {
"width": 556.5162909529794,
"height": 586.6978417266175,
"content": "## Translation
- Converts from speech to text.
- Translates the language from the native language to translated language (as specified in settings node)
"
},
"typeVersion": 1
},
{
"id": "c6947668-118e-4e23-bc55-1cdbce554a20",
"name": "Text reply",
"type": "n8n-nodes-base.telegram",
"position": [
2240,
220
],
"parameters": {
"text": "={{ $json.text }}",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"parse_mode": "Markdown"
}
},
"credentials": {
"telegramApi": {
"id": "Ov00cT0t4h4AFtZ0",
"name": "Telegram account"
}
},
"typeVersion": 1
},
{
"id": "93551aea-0213-420d-bf82-7669ab291dae",
"name": "Telegram1",
"type": "n8n-nodes-base.telegram",
"position": [
1060,
220
],
"parameters": {
"fileId": "={{ $('Telegram Trigger').item.json.message.voice.file_id }}",
"resource": "file"
},
"credentials": {
"telegramApi": {
"id": "Ov00cT0t4h4AFtZ0",
"name": "Telegram account"
}
},
"typeVersion": 1.1
},
{
"id": "972177e4-b0a4-424f-9ca6-6555ff3271d7",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1520,
400
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "fOF5kro9BJ6KMQ7n",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "0e8f610f-03a7-4943-bd19-b3fb10c89519",
"name": "Input Error Handling",
"type": "n8n-nodes-base.set",
"position": [
860,
220
],
"parameters": {
"fields": {
"values": [
{
"name": "message.text",
"stringValue": "={{ $json?.message?.text || \"\" }}"
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "c8ab9e01-c9b5-4647-8008-9157ed97c4c3",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
1920,
0
],
"parameters": {
"width": 585.8688089385912,
"height": 583.7625899280566,
"content": "## Telegram output
- Provide the output in both text as well as speech.
- Many languages are supported including English,French, German, Spanish, Chinese, Japanese.
Full list here:
https://platform.openai.com/docs/guides/speech-to-text/supported-languages
"
},
"typeVersion": 1
},
{
"id": "0898dc4d-c3ad-43df-871f-1896f673f631",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-140,
0
],
"parameters": {
"color": 4,
"width": 489.00549958607303,
"height": 573.4892086330929,
"content": "## Multi-lingual AI Powered Universal Translator with Speech ⭐
### Key capabilities
This flow enables a Telegram bot that can
- accept speech in one of 55 languages
- translates to another language and returns result in speech
### Use case:
- Learning a new language
- Communicate with others while traveling to another country
### Setup
- Open the Settings node and specify the languages you would like to work with"
},
"typeVersion": 1
},
{
"id": "ae0595d2-7e40-4c1e-a643-4b232220d19a",
"name": "Settings",
"type": "n8n-nodes-base.set",
"position": [
660,
220
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "501ac5cc-73e8-4e9c-bf91-df312aa9ff88",
"name": "language_native",
"type": "string",
"value": "english"
},
{
"id": "efb9a7b2-5baa-44cc-b94d-c8030f17e890",
"name": "language_translate",
"type": "string",
"value": "french"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "2d3654cf-a182-4916-a50c-a501828c2f6e",
"name": "Auto-detect and translate",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
1500,
220
],
"parameters": {
"text": "=Detect the language of the text that follows.
- If it is {{ $('Settings').item.json.language_native }} translate to {{ $('Settings').item.json.language_translate }}.
- If it is in {{ $('Settings').item.json.language_translate }} translate to {{ $('Settings').item.json.language_native }} .
- In the output just provide the translation and do not explain it. Just provide the translation without anything else.
Text:
{{ $json.text }}
",
"promptType": "define"
},
"typeVersion": 1.4
},
{
"id": "a6e63516-4967-4e81-ba5b-58ad0ab21ee3",
"name": "Audio reply",
"type": "n8n-nodes-base.telegram",
"position": [
2240,
400
],
"parameters": {
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"operation": "sendAudio",
"binaryData": true,
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "Ov00cT0t4h4AFtZ0",
"name": "Telegram account"
}
},
"typeVersion": 1.1
},
{
"id": "e4782117-03de-41d2-9208-390edc87fc08",
"name": "OpenAI2",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1300,
220
],
"parameters": {
"options": {},
"resource": "audio",
"operation": "transcribe"
},
"credentials": {
"openAiApi": {
"id": "fOF5kro9BJ6KMQ7n",
"name": "OpenAi account"
}
},
"typeVersion": 1.3
},
{
"id": "b29355f5-122c-4557-8215-28fdb523d221",
"name": "OpenAI",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
2020,
400
],
"parameters": {
"input": "={{ $json.text }}",
"options": {},
"resource": "audio"
},
"credentials": {
"openAiApi": {
"id": "fOF5kro9BJ6KMQ7n",
"name": "OpenAi account"
}
},
"typeVersion": 1.3
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "ac9c6f40-10c8-4b60-9215-8d4e253bf318",
"connections": {
"OpenAI": {
"main": [
[
{
"node": "Audio reply",
"type": "main",
"index": 0
}
]
]
},
"OpenAI2": {
"main": [
[
{
"node": "Auto-detect and translate",
"type": "main",
"index": 0
}
]
]
},
"Settings": {
"main": [
[
{
"node": "Input Error Handling",
"type": "main",
"index": 0
}
]
]
},
"Telegram1": {
"main": [
[
{
"node": "OpenAI2",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "Settings",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Auto-detect and translate",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Input Error Handling": {
"main": [
[
{
"node": "Telegram1",
"type": "main",
"index": 0
}
]
]
},
"Auto-detect and translate": {
"main": [
[
{
"node": "Text reply",
"type": "main",
"index": 0
},
{
"node": "OpenAI",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Telegramtrigger
- Stickynote
- Telegram
- @N8N/N8N Nodes Langchain.Lmchatopenai
- Set
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的Gmail账户
- n8n平台访问权限
- Google API凭证
- AI分类服务订阅
配置步骤
- 在n8n中导入工作流JSON文件
- 配置Gmail节点的认证信息
- 设置AI分类器的API密钥
- 自定义分类规则和标签映射
- 测试工作流执行
- 配置定时触发器(可选)
关键参数
| 参数名称 | 默认值 | 说明 |
|---|---|---|
| maxEmails | 50 | 单次处理的最大邮件数量 |
| confidenceThreshold | 0.8 | 分类置信度阈值 |
| autoLabel | true | 是否自动添加标签 |
最佳实践
优化建议
- 定期更新AI分类模型以提高准确性
- 根据邮件量调整处理批次大小
- 设置合理的分类置信度阈值
- 定期清理过期的分类规则
安全注意事项
- 妥善保管API密钥和认证信息
- 限制工作流的访问权限
- 定期审查处理日志
- 启用双因素认证保护Gmail账户
性能优化
- 使用增量处理减少重复工作
- 缓存频繁访问的数据
- 并行处理多个邮件分类任务
- 监控系统资源使用情况
故障排除
常见问题
邮件未被正确分类
检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。
Gmail认证失败
确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。
调试技巧
- 启用详细日志记录查看每个步骤的执行情况
- 使用测试邮件验证分类逻辑
- 检查网络连接和API服务状态
- 逐步执行工作流定位问题节点
错误处理
工作流包含以下错误处理机制:
- 网络超时自动重试(最多3次)
- API错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作